import React from 'react';
import {
  View,
  Text,
  TouchableOpacity,
} from 'react-native';

import SizeUtils from '../../common/SizeUtils';
import TImage from '../../components/TImage';
import Config from '../../config';
import CommonListPage from '../common/CommonListPage';
import JifenMallGetLuckerListAction from '../../actions/jifenmall/JifenMallGetLuckerListAction';

export default class JifenMyChoujiangPage extends CommonListPage {
  constructor(props) {
    super(props);

    this._dataKey = "award_id";
  }

  _getListViewStyle() {
    return {
        width:SizeUtils.getWindowSize().width,
        height:(SizeUtils.getWindowSize().height - Config.paddingTop - SizeUtils.translateDesignHeightToCode(40)),
        backgroundColor:"#ffffff00"};
  }

  _onPressItem(data, index) {
    this.gotoPage(Config.pages.jifenmall_choujiang_item_content, {itemData:data});
  }

  _onRenderItem(data, index) {
    return (
      <View style={{flexDirection:"column",
          width:SizeUtils.getWindowSize().width,
          borderColor:"#eeeeee", borderBottomWidth:SizeUtils.translateDesignNumToCode(3),
          paddingTop:SizeUtils.translateDesignHeightToCode(20),
          paddingBottom:SizeUtils.translateDesignHeightToCode(20),
          paddingLeft:SizeUtils.translateDesignHeightToCode(40),
          paddingRight:SizeUtils.translateDesignHeightToCode(40),
          }}>
        <View style={{flex:1,
            // backgroundColor:"#999999",
            flexDirection:"row"}}>
          <View style={{width:SizeUtils.translateDesignWidthToCode(99),
            height:SizeUtils.translateDesignWidthToCode(99),
            // backgroundColor:"#cccccc"
          }}>
            <TImage source={{uri:data.image_url}} style={{width:99, height:99}} resizeMode={"contain"}/>
          </View>
          <View style={{flex:1, flexDirection:"row", paddingLeft:SizeUtils.translateDesignWidthToCode(28),
              // backgroundColor:"#cccccc",
              alignItems:"center",
              paddingTop:SizeUtils.translateDesignHeightToCode(7), justifyContent:"space-between"}}>
            <Text style={{color:"#2e2e2e", fontSize:SizeUtils.translateFontSizeToCode(30)}}>
              {data.name}
            </Text>
            <Text style={{color:"#999999", fontSize:SizeUtils.translateFontSizeToCode(28)}}>
              {data.num} 个
            </Text>
          </View>
        </View>
      </View>
    )
  }

  _requestData(page, listView) {
    new JifenMallGetLuckerListAction().call(listView, {page:page, page_size:10, owned:1});
  }
}
